var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIBase"),
    s = t("UIConfig"),
    c = t("UIManager"),
    p = t("InvateItem"),
    l = cc._decorator,
    d = l.ccclass,
    u =
        (l.property,
        l.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.recList = [];
                e.tag = "InvateItem";
                return e;
            }
            e.prototype.onShowEnd = function () {
                var t = this;
                EVUIEffView.on(EVUIEffView.clickBoxItem, this.clickItem.bind(this), this);
                EVUIEffView.on(EVUIEffView.clickInvate, this.invateNode.bind(this), this);
                this.scheduleOnce(function () {
                    t.initView();
                });
            };
            e.prototype.invateNode = function (t, e) {
                CacheDataManager.setCurInvateData(e);
                this.closeUI();
            };
            e.prototype.clickItem = function (t, e, o, a, i) {
                e != this.tag || i || c.default.open(s.UIID.UIZhuanBeiDetail, {key: o, lv: a});
            };
            e.prototype.onCloseStart = function () {
                var t;
                EVUIEffView.offTarget(this);
                for (var e = 0; e < this.recList.length; e++) {
                    null === (t = this.recList[e]) || void 0 === t || t.recAll();
                    QLooperNode.putNode(this.recList[e].node);
                }
                this.recList.length = 0;
            };
            e.prototype.initView = function () {
                for (var t = this, e = [], o = 0; o < 20; o++) e.push(40101 + o);
                var a = CacheDataManager.getLastInvateDataList(),
                    i = function (o) {
                        var i = o;
                        n.scheduleOnce(function () {
                            var o = a[i],
                                n = Math.floor(Math.random() * e.length),
                                r = e.splice(n, 1)[0];
                            t.viewItem(o, i, r + "");
                        }, 0.05 * i);
                    },
                    n = this;
                for (o = 0; o < a.length; o++) i(o);
            };
            e.prototype.viewItem = function (t, e, o) {
                var a = this,
                    i = QLooperNode.getNode(QLooperNode.tag_invateItem);
                if (i) {
                    i.zIndex = e;
                    i.parent = this._content;
                    var n = i.getComponent(p.default);
                    n.tag = this.tag;
                    this.recList.push(n);
                    n.setData(t, o);
                } else
                    this.scheduleOnce(function () {
                        a.viewItem(t, e, o);
                    }, 0.1);
            };
            return n([d], e);
        })(r.default));
o.default = u;
